<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="../node_modules/vue/dist/vue.js"></script>
    <script src="../node_modules/axios/dist/axios.js"></script>
</head>
<body>
<div id="app">
    <h1>axios插件讲解</h1>
    <a href="javascript:;" @click="get">GET请求</a>
    <a href="javascript:;" @click="post">POST请求</a>

    <span>{{msg}}</span>
</div>

<script>
    new Vue({
        el: '#app',
        data: {
            msg: ''
        },
        methods: {
            get() {
                axios.get('../package.json', {
                    params: {
                        uid: 999
                    },
                    headers: {
                        token: 'jack'
                    }
                }).then(res => {
                    this.msg = res.data
                }).catch(error => {
                    console.log('error:' +  error)
                })
            },
            post() {
                axios.post('../package.json', {
                    params: {
                        uid: 999
                    },
                    headers: {
                        token: 'jack'
                    }
                }).then(res => {
                    this.msg = res.data
                }).catch(error => {
                    console.log('error:' +  error)
                })
            },
            http: function () {

            },
        }
    });
</script>

</body>
</html>